package com.ericpol.pageobject;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class LoginPage extends Page{
	
	public LoginPage(WebDriver driver) {
		super(driver);
	}
	
	public LoginPage openLoginPage() {
		driver.get("http://demo.bananascrum.com");
		return new LoginPage(driver);
	}
	
	public RecoveryPage openPasswordRecovery() {
		findAndClick(By.id("forgot-password"));
		return new RecoveryPage(driver);
	}
	
	protected boolean isOpen() {
		return isElementPresent(By.linkText("Login")) && !(isTextPresent("Unknown login"));
	}
	
	protected MainPage login(String user, String password) {
		insertText(By.id("login"), user);
		insertText(By.id("password"), password);
		findAndClick(By.name("commit"));
		return new MainPage(driver);
	}

}
